using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace OdsController {
	public partial class frmSplash : Form {
		public frmSplash(string softwareName) {
			InitializeComponent();
			lblSoftwareName.Text = softwareName;
			SetMensagem("Starting", -1);
		}
		
		public void SetMensagem(string @Mensagem) {
			this.lblMensagem.Text = Mensagem;
			this.BringToFront();
			this.Refresh();
		}
		public void SetMensagem(string @Mensagem, int progressValue) {
			this.lblMensagem.Text = Mensagem;
			SetProgress(progressValue);
		}

		public void SetProgress(int valor) {
			if (valor < 0) {
				progressbar.Style = ProgressBarStyle.Marquee;
			} else {
				progressbar.Style = ProgressBarStyle.Blocks;
				if (valor > 100) valor = 100;
				this.progressbar.Value = valor;
			}
			this.BringToFront();
			this.Refresh();
		}

		#region move
		private const int WM_NCLBUTTONDOWN = 0xA1;
		private const int HTCAPTION = 0x2;
		//---------------------------------------------------------------------------------------
		[DllImport("user32.dll")]
		public static extern bool ReleaseCapture();
		//---------------------------------------------------------------------------------------
		[DllImport("user32.dll")]
		public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
		//---------------------------------------------------------------------------------------
		private void form_progress_MouseDown(object sender, MouseEventArgs e) {
			if (e.Button == MouseButtons.Left) {
				ReleaseCapture();
				SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
			}
		}
		#endregion move
	}
}